package 第六章作业;

import java.util.Scanner;

public class 第六章作业2 {
    public static void main(String[] args) {
        /*2)、计算用户输入的日期离1900年1月1日相距多少天。
        （注意闰年，每个月份天数不一样）*/
        int  mouth, year, day = 0;
        int num =0;
        int sum = 0;
        int total =0;
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入年份：");
        year = sc.nextInt();
        System.out.print("请输入月份：");
        mouth = sc.nextInt();
        System.out.print("请输入日期：");
        day = sc.nextInt();
        if (year / 4 == 0 && year / 100 != 0||year/400!=0) {
            num = 1;
        }
        switch (mouth - 1) {
            case 11:
                sum += 30;
            case 10:
                sum += 31;
            case 9:
                sum += 30;
            case 8:
                sum += 31;
            case 7:
                sum += 31;
            case 6:
                sum += 30;
            case 5:
                sum += 31;
            case 4:
                sum += 30;
            case 3:
                sum += 31;
            case 2:
                sum += 28 +num ;
            case 1:
                sum += 31;
                break;
        }
        sum+=day;
        if(year>=1900){
            for (int i = 1900; i <year ; i++) {
                if(year/4==0&&year/100!=0||year/400!=0){
                    total+=366;
                }
                else{
                    total+=365;
                }
            }
            System.out.println("这一天离1900年1月1日"+(total+sum-1)+"天");
        }
        else{
            for (int i = 1900; (i-1) > year; i--) {
                if(year/4==0&&year/100!=0||year/400!=0){
                    total+=366;
                }
                else{
                    total+=365;
                }
            }
            if(year/4==0&&year/100!=0||year/400!=0){
                System.out.println("您输入的日期离1900年1月1日是："+(366-sum+total+1)+"天");
            }

        }
    }
}
